import {
	ref
} from 'vue'
const db = uniCloud.database()

export let addPopup = ref()
// 搜索关键词
export let query = ref("")
export let onSearch = () => {
	console.log(query.value, '搜索')
}

// 表单数据
	export let addFormData = ref({
		name: '默认文件',
		src: '',
		cover: ''
	})
	
	
export let onAddFn = async () => {
	console.log(addFormData.value,'新增')
	uni.showLoading({
		title: '提交中...',
		mask: true
	})
	let collection=await db.collection('uni-media-library')
	let res = await collection.add(addFormData.value)
	console.log(res,'res')
	if(res.result&&res.result.id){
		uni.showToast({
			title: '新增成功'
		})
	}else{
		uni.showModal({
			content: err.message || '请求服务失败',
			showCancel: false
		})
	}
	uni.hideLoading()
	addPopup.value.close()
}
export let onDelete = () => {
	console.log('删除')
}

export let selectedIndexs=ref([])